package com.yunji.web.cabinet;

import com.yunji.cabinet.domain.ContainerTypeDO;
import com.yunji.cabinet.service.impl.CabinetBaseService;
import com.yunji.common.base.response.Response;
import com.yunji.common.base.response.ResponseHelper;
import com.yunji.common.utils.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * @Package com.yunji.web.cabinet
 * FileName:	ContainerShapeController.java
 * Copyright:	Copyright © 2024 云集互联 All Rights Reserved
 * Company:		云集互联
 * @version: 1.0
 * @since: JDK 1.8.0_202
 * Create at:   2024-04-01 09:31:06
 * Description:
 * 货柜外形交互
 * Modification History:
 * Author					Date						Version			Description
 * --------------------------------------------------------------------------------
 * HuaAo				2024-04-01 09:31:06			1.0				1.0 Version
 */
@Api(tags = "管理端-货柜类型")
@RestController
@RequestMapping("/container/base")
public class CabinetBaseController {
    @Resource
    private CabinetBaseService service;

//    @ApiOperation("查询货柜外形列表")
//    @GetMapping("/shapeList")
//    public Response<List<ContainerShapeDO>> shapeList() {
//        List<ContainerShapeDO> list = service.shapeList();
//        return ResponseHelper.successWithPage(list);
//    }
//
//    @ApiOperation("导出货柜外形列表")
//    @PostMapping("/exportShape")
//    public void exportShape(HttpServletResponse response) {
//        List<ContainerShapeDO> list = service.shapeList();
//        ExcelUtil<ContainerShapeDO> util = new ExcelUtil<ContainerShapeDO>(ContainerShapeDO.class);
//        util.exportExcel(response, list, "货柜外形数据");
//    }
//
//    @ApiOperation("获取货柜外形详细信息")
//    @GetMapping("/shape/{id}")
//    public Response<ContainerShapeDO> shape(@PathVariable("id") Long id) {
//        return ResponseHelper.success(service.getShapeById(id));
//    }
//
//    @ApiOperation("新增货柜外形")
//    @PostMapping("/createShape")
//    public Response<Integer> createShape(@RequestBody ContainerShapeDO shape) {
//        return ResponseHelper.success(service.createShape(shape));
//    }
//
//    @ApiOperation("修改货柜外形")
//    @PutMapping("/updateShape")
//    public Response<String> updateShape(@RequestBody ContainerShapeDO shape) {
//        service.updateShape(shape);
//        return ResponseHelper.success();
//    }
//
//    @ApiOperation("删除货柜外形")
//    @DeleteMapping("/deleteShape/{id}")
//    public Response<String> deleteShape(@PathVariable Long id) {
//        service.deleteShape(id);
//        return ResponseHelper.success();
//    }


    @ApiOperation("查询货柜类型列表")
    @GetMapping("/typeList")
//    @PreAuthorize("@ss.hasPermi('container:containerType:list')")
    public Response<List<ContainerTypeDO>> typeList() {
        List<ContainerTypeDO> list = service.typeList();
        return ResponseHelper.successWithPage(list);
    }

    @ApiOperation("导出货柜类型列表")
    @PostMapping("/exportType")
    @PreAuthorize("@ss.hasPermi('container:containerType:export')")
    public void export(HttpServletResponse response) {
        List<ContainerTypeDO> list = service.typeList();
        ExcelUtil<ContainerTypeDO> util = new ExcelUtil<>(ContainerTypeDO.class);
        util.exportExcel(response, list, "货柜类型数据");
    }

    @ApiOperation("获取货柜类型详细信息")
    @GetMapping(value = "/getType/{code}")
    public Response<ContainerTypeDO> getType(@PathVariable("code") String typeCode) {
        return ResponseHelper.success(service.getTypeById(typeCode));
    }

    @ApiOperation("修改货柜类型")
    @PutMapping(value = "/updateType")
    @PreAuthorize("@ss.hasPermi('container:containerType:edit')")
    public Response<String> updateType(@RequestBody ContainerTypeDO domain) {
        service.updateType(domain);
        return ResponseHelper.success();
    }


//    @ApiOperation("新增货柜类型")
//    @PostMapping
//    public Response<String> createType(@RequestBody ContainerTypeDO domain) {
//        return ResponseHelper.success(service.createType(domain));
//    }



//    @ApiOperation("删除货柜类型")
//    @DeleteMapping("/removeType/{id}")
//    public Response<String> removeType(@PathVariable Long id) {
//        service.deleteType(id);
//        return ResponseHelper.success();
//    }
}
